#include<iostream>
#include<cstring>

using namespace std;

char map[4][4] = {0};
int  maxt = 0;

bool legal(int a, int b)
{
	int i;
	
	if (map[a][b]=='X' || map[a][b] == '+') {
		return false;
	}
	
	for (i = a - 1; i >= 0; i--) {
		if (map[i][b] == '+') {
			return false;
		} else if(map[i][b] == 'X') {
			break;
		}
	}
	
	for (i = b - 1; i >= 0; i--) {
		if(map[a][i] == '+') {
			return false;
		} else if(map[a][i] == 'X') {
			break;
		}
	}
	
	return true;
}

void maker(int k, int count, int n)
{
	int i, j;
	
	if (k == n * n) {
		if (count > maxt) {
			maxt = count;
		}
		return;
	} else {
		i = k / n;
		j = k % n;
		
		if (legal(i, j)) {
			map[i][j] = '+';
			maker(k + 1, count + 1, n);
			map[i][j] = '.';
		}

		maker(k + 1, count, n);
	}
}

int main(int argc, char * argv[])
{
	int n;
	int i, j;

	while(cin >> n) {
		if (n == 0) {
			break;
		}

		for (i = 0; i < n; i++)
			for(j = 0; j < n; j++)
				cin >> map[i][j];

		maxt = 0;
		maker(0, 0, n);
		cout << maxt << endl;
	}
}
